<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>组合式继承(原型链继承和借用构造函数合并)</title>
	</head>
	<body>
		优点:
		1、解决了每个实例对引用类型属性的修改都会被其他的实例共享的问题
		2、子类可以向父类传参
		3、可实现父类方法复用
		
		缺点:
		1、需执行两次父类构造函数，第一次是Child.prototype = new Parent(),第二次是Parent.call(this, name)造成不必要的浪费

		<script type="text/javascript">
			
			function Parent(name) {
				this.name = name
				this.course = ['react', 'vue']
			}

			function Child(name, age) {
				Parent.call(this, name)
				this.age = age
			}

			Child.prototype = new Parent()
			Child.prototype.constructor = Child

			var combinedExtend1 = new Child('bob', '18')
			combinedExtend1.course.push('node')
			
			console.log(combinedExtend1.name, combinedExtend1.age) // bob 18
			console.log(combinedExtend1.course) // ["react", "vue", "node"]

			var combinedExtend2 = new Child('lala', '20')
			combinedExtend2.course.push('angular')
			
			console.log(combinedExtend2.name, combinedExtend2.age) // lala 20
			console.log(combinedExtend2.course) // ["react", "vue", "angular"]
			
		</script>
	</body>
</html>
